package com.mmy.fta.trade.server.repository;

import com.mmy.fta.trade.server.entity.OrderEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface OrderEntityMapper {
    int insert(OrderEntity record);

    int insertSelective(OrderEntity record);

    OrderEntity selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(OrderEntity record);

    int updateByPrimaryKey(OrderEntity record);

    List<OrderEntity> queryTransportOrdersByDriver(String carrierOpenid);

    List<OrderEntity> queryTransportOrdersByShipper(String consignorOpenId);

    List<OrderEntity> queryCanceledOrderOrdersByDriver(String carrierOpenid);

    List<OrderEntity> queryCanceledOrderOrdersByShipper(String consignorUserId);

    List<OrderEntity> queryCompletedOrdersByDriver(String carrierOpenId);

    List<OrderEntity> queryCompletedOrdersByShipper(String consignorUserId);


    int agreeOrderByShipper(@Param("orderNumber") String orderNumber,
                            @Param("shipperAgreeTime") Date shipperAgreeTime,
                            @Param("updateTime") Date updateTime);

    int refuseOrderByShipper(@Param("orderNumber") String orderNumber,
                             @Param("shipperRefuseTime") Date shipperRefuseTime,
                             @Param("updateTime") Date updateTime);

    int cancelOrderByShipper(@Param("orderNumber") String orderNumber,
                             @Param("shipperCancelTime") Date shipperCancelTime,
                             @Param("updateTime") Date updateTime);

    int receiveOrderByShipper(@Param("orderNumber") String orderNumber,
                              @Param("shipperReceiveTime") Date shipperReceiveTime,
                              @Param("finishTime")Date finishTime,
                              @Param("updateTime") Date updateTime);

    int cancelOrderByDriver(@Param("orderNumber") String orderNumber,
                            @Param("driverCancelTime") Date driverCancelTime,
                            @Param("updateTime") Date updateTime);

    int loadOrderByDriver(@Param("orderNumber") String orderNumber,
                          @Param("driverLoadTime") Date driverLoadTime,
                          @Param("updateTime") Date updateTime);

    int unloadOrderByDriver(@Param("orderNumber") String orderNumber,
                            @Param("driverUnloadTime") Date driverUnloadTime,
                            @Param("updateTime") Date updateTime);

    String selectCargoIdByOrderNumber(String orderNumber);

    OrderEntity queryOrderDetail(String orderNumber);

    int republishCargo(@Param("cargoId") String cargoId,@Param("updateTime") Date updateTime);
}